package com.linln.admin.system.controller;

import com.github.pagehelper.Page;
import com.linln.common.utils.HttpServletUtil;
import org.springframework.util.StringUtils;

/**
 * 分页排序数据
 * @author 小懒虫
 * @date 2018/12/8
 */
public class PageSort {

    public static final Integer PAGE_NUMBER_DEF = 1;
    public static final Integer PAGE_SIZE_DEF = 10;
    public static final String ORDER_BY_COLUMN_DEF = "createDate";
    public static final String SORT_DIRECTION = "desc";



    /**
     * 带条件的分页查询---处理前端的请求参数
     * @return
     */
    public static Page getPageInfoFromRequest(){

        int pageNum = HttpServletUtil.getParameterInt("page", PAGE_NUMBER_DEF);
        int pageSize = HttpServletUtil.getParameterInt("size", PAGE_SIZE_DEF);
//        String orderByColumn = HttpServletUtil.getParameter("orderByColumn", ORDER_BY_COLUMN_DEF);
//        String direction = HttpServletUtil.getParameter("isAsc", SORT_DIRECTION);
        return new Page(pageNum <= 0 ?  1 : PAGE_NUMBER_DEF , pageSize <= 0 ?  10 :PAGE_SIZE_DEF);
    }
}
